/*****************************************************************************/
/*                                                                           */
/*    Domino Operation System System Specific Module                         */
/*                                                                           */
/*    Copyright (C) 2010 Laszlo Arvai                                        */
/*                                                                           */
/*    ------------------------------------------------------------------     */
/*    netUtils - General network related utility                             */
/*****************************************************************************/

/*****************************************************************************/
/* Includes                                                                  */
/*****************************************************************************/
#include <netUtils.h>

/*****************************************************************************/
/* Constants                                                                 */
/*****************************************************************************/

/*****************************************************************************/
/* Functions                                                                 */
/*****************************************************************************/

///////////////////////////////////////////////////////////////////////////////
//! Converts MAC address to string
//! \param MAC address to convert
/*
void netMACAddressToString( dosString out_buffer, dosStringLength in_buffer_length, MAC_ADDR &in_mac_addr )
{
	dosByte i;
	dosByte pos = 0;

	i = 0;
	while(1)
	{
		strWordToHexStringPos( out_buffer, in_buffer-length, pos, mac_address.v[i]

		netWriteByteTXPacket(charNibbleToHex(>>4));
		netWriteByteTXPacket(charNibbleToHex(mac_address.v[i]&0x0f));
    if(++i == 6u)
	   	break;
		netWriteByteTXPacket('-');
	}

}
*/

///////////////////////////////////////////////////////////////////////////////
//! Converts IP address to string
//! \param Buffer to receive the string
//! \param Length of the buffer
//! \param IP address to convert
//! \return Number of stored character
dosByte netIPAddressToString( dosString out_buffer, dosStringLength in_buffer_length, IN_ADDR* in_ip_addr )
{
	dosByte i;
	dosByte pos = 0;

	// convert IP address
	i = 0;
	while( (pos-1) < in_buffer_length )
	{
		pos += strWordToStringPos( out_buffer, in_buffer_length, pos, in_ip_addr->v[i], 0, 0, 0 );

		if(++i == 4)
	   	break;

		out_buffer[pos++] = '.';
	}

	// terminate string
	out_buffer[pos] = '\0';

	return pos;
}
